package com.example.excel;
import com.alibaba.excel.EasyExcel;
import java.util.ArrayList;

public class ExcelWrite {
  public static void main(String[] args){
      ArrayList<UserData> list = new ArrayList<>();
      for(int i=0;i<20;i++){
          UserData userData = new UserData();
          userData.setId(i);
          userData.setUsername("tenghw"+i);
          userData.setGender("男");
          userData.setSalary(15000.00);
          list.add(userData);
      }
      //设置excel文件路径和文件名,需事先创建exceldemo文件夹
      String fileName = "E:\\exceldemo\\01.xlsx";
      // write方法实现写操作
      EasyExcel.write(fileName,UserData.class).sheet("用户信息").doWrite(list);
  }
}